package com.life.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JRadioButton;
import javax.swing.JToggleButton;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class RadioButtonAdapter extends AbstractAdapter implements FocusListener, ActionListener {

    	JToggleButton theRadioButton = null;
	
	public RadioButtonAdapter(JToggleButton radioButton)
	{
		theRadioButton = radioButton;
		theRadioButton.addFocusListener(this);
		theRadioButton.addActionListener(this);
		
	}
	
	@Override
	public Object get() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setEnabled(boolean value) {
		theRadioButton.setEnabled(value);

	}

	public void focusGained(FocusEvent arg0) {
		
	}

	public void focusLost(FocusEvent arg0) {
	}

	@Override
	public void set(Object data) {
		theRadioButton.setText(data.toString());
		
	}
	
	public void setSelected(boolean val)
	{
		theRadioButton.setSelected(val);
	}
	
	public boolean isSelected()
	{
		return theRadioButton.isSelected();
	}

	public void actionPerformed(ActionEvent e)
	{

	    setChanged();
	    notifyObservers();
	    
	}

}
